package com.yb.designpattern.structure.proxy.dongt;

import com.yb.designpattern.structure.proxy.Subject;
import com.yb.designpattern.structure.proxy.SubjectImpl;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class Client {

    public static void main(String[] args) {
        //要代理的对象
        Subject subjectImpl = new SubjectImpl();
        //动态代理类
        InvocationHandler handler = new DynamicProxy(subjectImpl);
        //创建要代理的对象
        Subject subject = (Subject) Proxy.newProxyInstance(handler.getClass().getClassLoader(), subjectImpl.getClass().getInterfaces(), handler);
        subject.a();
    }
}
